package com.ljf.authority.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.authority.domain.repository.AuthorityBaseApiTabulationRepository;
import com.ljf.authority.dto.query.AuthorityBaseApiTabulationQuery;
import com.ljf.authority.infra.mapper.AuthorityBaseApiTabulationMapper;
import com.ljf.authority.model.AuthorityBaseApiTabulation;
import com.ljf.authority.vo.AuthorityBaseApiTabulationVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.common.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * API列表定义  数据访问接口实现
 *
 * @author LJF
 * @since 2024-10-25
 */
@Component
public class AuthorityBaseApiTabulationRepositoryImpl extends BasisRepositoryImpl<AuthorityBaseApiTabulationMapper, AuthorityBaseApiTabulation, AuthorityBaseApiTabulationQuery, AuthorityBaseApiTabulationVO> implements AuthorityBaseApiTabulationRepository {

    @Override
    protected QueryWrapper<AuthorityBaseApiTabulation> fillWrapper(AuthorityBaseApiTabulationQuery query, boolean sort) throws ServiceException {
        QueryWrapper<AuthorityBaseApiTabulation> wrapper = super.fillWrapper(query, sort);
        if (CollectionUtil.isNotEmpty(query.getCodeList())) {
            wrapper.in(AuthorityBaseApiTabulation.COL_CODE, query.getCodeList());
        }
        if (CollectionUtil.isNotEmpty(query.getIds())) {
            wrapper.in(AuthorityBaseApiTabulation.COL_ID, query.getIds());
        }
        if (StringUtil.isNotEmpty(query.getCodeLike())) {
            wrapper.like(AuthorityBaseApiTabulation.COL_CODE, query.getCodeLike());
        }
        return wrapper;
    }

}
